#!/bin/sh /usr/share/dpatch/dpatch-run
## 01-track-size.dpatch by Piotr Kaczuba <pepe@attika.ath.cx>
##
## DP: Fix wrong track size calculation when having multiple tracks in one image
## DP: (Closes: #261274).

@DPATCH@

diff -Naur bchunk-1.2.0.orig/bchunk.c bchunk-1.2.0/bchunk.c
--- bchunk-1.2.0.orig/bchunk.c	2004-06-29 20:42:33.000000000 +0000
+++ bchunk-1.2.0/bchunk.c	2006-09-08 18:19:59.000000000 +0000
@@ -476,7 +476,7 @@
 			if (verbose)
 				printf(" (startsect %ld ofs %ld)", track->startsect, track->start);
 			if ((prevtrack) && (prevtrack->stopsect < 0)) {
-				prevtrack->stopsect = track->startsect;
+				prevtrack->stopsect = track->startsect - 1;
 				prevtrack->stop = track->start - 1;
 			}
 		}
@@ -484,7 +484,7 @@
 	
 	if (track) {
 		fseek(binf, 0, SEEK_END);
-		track->stop = ftell(binf);
+		track->stop = ftell(binf) - 1;
 		track->stopsect = track->stop / SECTLEN;
 	}
 	
